﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace ICeFramework.Win.UI
{
    public class ICButton : Button
    {
        private bool _mouseDown = false;
        public ICButton()
        {

        }
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
        }

        protected override void OnMouseDown(MouseEventArgs mevent)
        {
            base.OnMouseDown(mevent);
            _mouseDown = true;
            this.Invalidate();
        }

        protected override void OnMouseUp(MouseEventArgs mevent)
        {
            base.OnMouseUp(mevent);
            _mouseDown = false;
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;
            Brush linearGradientBrush = new LinearGradientBrush(pevent.ClipRectangle, Color.Aqua, Color.White, 45);
            if (_mouseDown)
            {
                linearGradientBrush = new LinearGradientBrush(pevent.ClipRectangle, Color.Blue, Color.White, 45);
            }
            g.FillRectangle(linearGradientBrush, pevent.ClipRectangle);
            linearGradientBrush.Dispose();
        }
    }
}
